//
//  MineMainTabHeaderView.m
//  CarUser
//
//  Created by ayi on 2018/12/24.
//  Copyright © 2018 王森林. All rights reserved.
//

#import "MineMainTabHeaderView.h"

@implementation MineMainTabHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
//        UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, BOUNDWIDTH, self.frame.size.height)];
//        bgImageView.image = IMG(@"bg_title");
//        [self addSubview:bgImageView];
        
        _headerImgv = [[UIImageView alloc]init];
      
        _nameLab = [UILabel customInitLabWithFont:18 andTextColor:UIColor.whiteColor andAlign:NSTextAlignmentLeft];
        _nameLab.font = B_FONT_SIZE(18);
        _contentLab = [UILabel customInitLabWithFont:14 andTextColor:UIColor.whiteColor andAlign:NSTextAlignmentLeft];
        _pushBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_pushBtn addTarget:self action:@selector(pushBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:_headerImgv];
        [self addSubview:_nameLab];
        [self addSubview:_contentLab];
        [self addSubview:_pushBtn];
        
        _headerImgv.frame = CGRectMake(0, 0 , 60, 60);
        _headerImgv.center = CGPointMake(15 + CGRectGetWidth(_headerImgv.frame)/2, CGRectGetHeight(frame)/2 + 15);
        _headerImgv.layer.cornerRadius = 30;
        _headerImgv.layer.masksToBounds = YES;
        
        _nameLab.frame = CGRectMake(CGRectGetMaxX(_headerImgv.frame) + 10, CGRectGetMinY(_headerImgv.frame) + CGRectGetHeight(_headerImgv.frame)/2 - _nameLab.font.lineHeight - 2, BOUNDWIDTH - (CGRectGetMaxX(_headerImgv.frame) + 10 + 15), _nameLab.font.lineHeight);
        _contentLab.frame = CGRectMake(CGRectGetMaxX(_headerImgv.frame) + 10, CGRectGetMinY(_headerImgv.frame) + CGRectGetHeight(_headerImgv.frame)/2 + 2, BOUNDWIDTH - (CGRectGetMaxX(_headerImgv.frame) + 10 + 15), _contentLab.font.lineHeight);
        
        _pushBtn.frame = CGRectMake(15, CGRectGetHeight(frame)/2 - CGRectGetHeight(_headerImgv.frame)/2, CGRectGetWidth(_headerImgv.frame) + 10 + 40, CGRectGetHeight(_headerImgv.frame));
    }
    return self;
}

- (void)pushBtnAction{
    if (self.delegate && [self.delegate respondsToSelector:@selector(mineMainAction)]) {
        [self.delegate mineMainAction];
    }
}

@end
